package com.msh.feignService;

import com.msh.feignService.fallback.OrderServiceFallbackFactory;
import com.msh.viewmodel.OrderViewModel;
import com.msh.viewmodel.Pager;
import com.msh.viewmodel.RequestPay;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

/**
 * @author :zhangchuanfu
 * @Date :2023/1/14
 * @Time :18:39
 * @description :订单微服务远程调用
 */
@FeignClient(value = "order-service",fallbackFactory = OrderServiceFallbackFactory.class)
public interface OrderService {
    @PostMapping("/wxpay/requestpay")
    String requestPay(@RequestBody RequestPay requestPay);

    @GetMapping("/order/cancel/{orderNo}")
    Boolean cancel(@PathVariable String orderNo);

    @GetMapping("/order/search")
    Pager<OrderViewModel> search(
            @RequestParam(value = "pageIndex",required = false,defaultValue = "1") Integer pageIndex,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize,
            @RequestParam(value = "orderNo",required = false,defaultValue = "") String orderNo,
            @RequestParam(value = "openId",required = false,defaultValue = "") String openId,
            @RequestParam(value = "startDate",required = false,defaultValue = "") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
            @RequestParam(value = "endDate",required = false,defaultValue = "") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate  endDate
    );

    @GetMapping("/order/businessTop10/{businessId}")
    List<Long> getBusinessTop10Skus(@PathVariable Integer businessId);
}
